import { http } from './http'
import { PageQueryParams, PageResponse } from '@/config/page'

export interface DocCommentCreateParams {
  docId: number;

  content: string;
}

export interface DocReplyCreateParams {
  commentId: number;

  content: string;

  repliedBy?: number;
}

/**
 * 获取文件评论列表。
 */
export function queryCommentsByDoc (docId: number, params: PageQueryParams) {
  return http().get<PageResponse<any>>(`/api/document/doc-comments/doc/${docId}`, { params })
}

/**
 * 创建评论。
 * @param params
 */
export function createComment (params: DocCommentCreateParams): Promise<any> {
  return http().post<any>('/api/document/doc-comments', params)
}

/**
 * 删除评论。
 */
export function deleteComment (commentId: number): Promise<any> {
  return http().delete<any>(`/api/document/doc-comments/${commentId}`)
}

/**
 * 创建回复。
 * @param params
 */
export function createReply (params: DocReplyCreateParams): Promise<any> {
  return http().post<any>('/api/document/doc-replies', params)
}

/**
 * 删除回复。
 */
export function deleteReply (replyId: number): Promise<any> {
  return http().delete<any>(`/api/document/doc-replies/${replyId}`)
}
